package com.project.cotroller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RequestMapping("user")
@RestController
public class UserController {
    @RequestMapping("login")
    public String login(String userName, String pwd, String code, HttpServletRequest request){
        //得到服务器产生的验证码
        String userCode = (String) request.getSession().getAttribute("userCode");
        if (code.equals(userCode)==false){
            return "验证码不正确";
        }

        if ("java".equalsIgnoreCase(userName)&&"123".equals(pwd)){
            return "登陆成功";
        }
        return "登陆失败";
    }
}
